package cn.edu.nuc.carsystem.Interecptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import cn.edu.nuc.carsystem.model.Custome;
import cn.edu.nuc.carsystem.model.SysUser;


public class AuthInterceptor implements HandlerInterceptor {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		request.getRequestURI();
		HttpSession session = request.getSession();
		SysUser	yxqUser = (SysUser)session.getAttribute("sysUser");
		
		if( yxqUser != null ){
			System.out.println("bualnjie ");
			return true;
		}
		else{
			System.out.println("lanjie555 ");
			response.sendRedirect("/admin");
		}
		    return false;
	
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

}
